<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<div id="menuImpiegato">
		<ui:include src="/pagine_impiegati/commonHeader.xhtml" />
	</div>
</h:head>


<h:body>
	<p:growl id="growl" showDetail="true" />

	<h:form id="form">
		<p:inputMask value="#{pacchettoBean.ric}" />
		<p:commandButton icon="ui-icon-search" value="Cerca per Città"
			action="#{pacchettoBean.ricercaCitta()}" update="form" />
		<p:commandButton icon="ui-icon-search" value="Cerca per Nome"
			action="#{pacchettoBean.ricercaNome()}" update="form" />

		<p:dataList id="packs" value="#{pacchettoBean.pacchetti}"
			var="packDTO" paginator="true" rows="5"
			paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
			rowsPerPageTemplate="5,10,15" type="none">

			<f:facet name="header">  
                Elenco pacchetti  
            </f:facet>

			<p:commandButton icon="ui-icon-search" update=":form:packDetail"
				oncomplete="PF('packDialog').show()" title="Vedi Dettagli">
				<f:setPropertyActionListener value="#{packDTO}"
					target="#{pacchettoBean.selectPack}" />
			</p:commandButton>
			
			<p:commandButton icon="ui-icon-pencil" action = "/pagine_impiegati/modificaPacchetto?faces-redirect=true" title="Modifica">
				<f:setPropertyActionListener value="#{packDTO}" target="#{prenotazBean.selectPack}" />
			</p:commandButton>


			<p:commandButton icon="ui-icon-trash"
				action="#{pacchettoBean.confirmDel()}" update=":form:packs" >
				<f:setPropertyActionListener value="#{packDTO}"
					target="#{pacchettoBean.selectPack}" />
				<p:confirm header="Conferma"
					message="Sei sicuro di cancellare il pacchetto?"
					icon="ui-icon-alert" />
			</p:commandButton>

			<p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
				<p:commandButton value="Yes" type="button"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="No" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>


			<h:outputText value="#{packDTO.nome}, #{packDTO.prezzo}"
				style="margin-left:10px" />

			<br />
		</p:dataList>

		<p:dialog header="Pack Detail" widgetVar="packDialog" modal="true"
			showEffect="fade">
			<p:outputPanel id="packDetail" style="text-align:center;"
				layout="block">


				<h:panelGrid columns="2" cellpadding="5">
					<h:outputLabel for="nome" value="Nome Pacchetto: " />
					<h:outputText id="nome" value="#{pacchettoBean.selectedPack.nome}" />

					<h:outputLabel for="postiDisponibili" value="Posti disponibili: " />
					<h:outputText id="postiDisponibili"
						value="#{pacchettoBean.selectedPack.numeroPosti}" />

					<h:outputLabel for="prezzo" value="Prezzo: " />
					<h:outputText id="prezzo"
						value="#{pacchettoBean.selectedPack.prezzo}" />

					<h:outputLabel for="dataPartenza" value="Data Partenza: " />
					<h:outputText id="dataPartenza"
						value="#{pacchettoBean.selectedPack.dataPartenza}" >
						<f:convertDateTime type = "date"/>
					</h:outputText>	

					<h:outputLabel for="volo" value="Data Ritorno: " />
					<h:outputText id="volo"
						value="#{pacchettoBean.selectedPack.dataArrivo}" >
						<f:convertDateTime type = "date"/>
					</h:outputText>	
				</h:panelGrid>
			</p:outputPanel>
		</p:dialog>

	</h:form>


</h:body>
</html>